﻿using System.ComponentModel;
using Util;

namespace IterationLife.Extensions.Enums
{
    /// <summary>
    /// 文件类型
    /// </summary>
    public enum FileType
    {
        /// <summary>
        /// 图片
        /// </summary>
        [Description("图片")]
        Picture = 1,
        /// <summary>
        /// 音频
        /// </summary>
        [Description("音频")]
        Audio = 2,
        /// <summary>
        /// 视频
        /// </summary>
        [Description("视频")]
        Video = 3,
        /// <summary>
        /// 网页
        /// </summary>
        [Description("网页")]
        Web = 4,
        /// <summary>
        /// 压缩包
        /// </summary>
        [Description("压缩包")]
        Zip = 5,
        /// <summary>
        /// 其他
        /// </summary>
        [Description("文件")]
        Other = 6,
        /// <summary>
        /// vr
        /// </summary>
        [Description("vr")]
        Vr = 7
    }

    /// <summary>
    /// 文件类型枚举扩展
    /// </summary>
    public static class FileTypeExtensions
    {
        /// <summary>
        /// 获取描述
        /// </summary>
        public static string Description(this FileType? type)
        {
            return type == null ? string.Empty : type.Value.Description();
        }

        /// <summary>
        /// 获取值
        /// </summary>
        public static int? Value(this FileType? type)
        {
            return type?.Value();
        }

        /// <summary>
        /// 扩展名
        /// </summary>
        public static string Extensions(this FileType? type)
        {
            switch (type)
            {
                case FileType.Picture:
                    return "JPG|jpg|PNG|png|JPEG";
                case FileType.Audio:
                    return "mp3|wav";
                case FileType.Video:
                    return "flv|mkv|mp4|rmvb|avi";
                case FileType.Web:
                    return "html";
                case FileType.Zip:
                    return "zip";
                default:
                    return string.Empty;
            }
        }
    }
}
